<template>
  <div class="home">
    <el-input v-model="input" @input="search" placeholder="请输入内容"></el-input>
    <el-table
      :data="tableData"
      style="width: 100%"
      :default-sort="{ prop: 'date', order: 'descending' }"
    >
      <el-table-column prop="right" label="编号" sortable> </el-table-column>
      <el-table-column prop="title" label="名称"> </el-table-column>
      <el-table-column prop="price" label="价格" sortable> </el-table-column>
    </el-table>
    <el-pagination background layout="prev, pager, next" :total="10" :size="5">
    </el-pagination>
  </div>
</template>


<script>
import jsonData from "@/assets/data(2)(2)(1).json";
console.log(jsonData);
export default {
  data() {
    return {
      input: "",
      tableData: [],
    };
  },
  mounted() {
    this.tableData = jsonData.data;
  },
  methods: {
    search(){
      // console.log(111)
      if(this.input==''){
        return alert('内容不能为空')
      }
      this.tableData=this.tableData.filter(item=>{
        return item.title.includes(this.input)
      })
    }
  },
};
</script>



<style lang="sass">
</style>